//
//  CollectTableViewCell.m
//  carcar
//
//  Created by dlios on 15/9/15.
//  Copyright (c) 2015年 DIOS. All rights reserved.
//

#import "CollectTableViewCell.h"
#import "BaseHeader.h"

@implementation CollectTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.modelNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(5 * suitableScreen_Width , 10 * suitableScreen_Width, 365 * suitableScreen_Width, 40* suitableScreen_Width)];
        [self.contentView addSubview:self.modelNameLabel];
        [self.modelNameLabel setNumberOfLines:0];
        self.modelNameLabel.alpha = 0.8 ;
        [self.modelNameLabel setFont:[UIFont systemFontOfSize:18 * suitableScreen_Width]];
        self.dealerNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(5 * suitableScreen_Width, 50 * suitableScreen_Width, 350 * suitableScreen_Width, 25 * suitableScreen_Width)];
        [self.contentView addSubview:self.dealerNameLabel];
        [self.dealerNameLabel setFont:[UIFont systemFontOfSize:14 * suitableScreen_Width]];
        
        
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(10 *suitableScreen_Width , 75 * suitableScreen_Width, mainScreen_Width / 2, 25 * suitableScreen_Width)];
        [self.contentView addSubview:self.priceLabel];
        [self.priceLabel setTextAlignment:NSTextAlignmentLeft];
        [self.priceLabel setTextColor:[UIColor blackColor]];
        
        self.decline = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 2, 75 * suitableScreen_Width, mainScreen_Width/ 2, 25 * suitableScreen_Width)];
        [self.contentView addSubview:self.decline];
        [self.decline setTextAlignment:NSTextAlignmentLeft];
        [self.decline setTextColor:[UIColor blackColor]];
        
        self.phoneLabel = [[UIButton alloc]initWithFrame:CGRectMake(5 * suitableScreen_Width, 100 * suitableScreen_Width, 365 * suitableScreen_Width, 25 * suitableScreen_Width)];
        [self.contentView addSubview:self.phoneLabel];
        
        [self.phoneLabel setTitleColor:[UIColor colorWithRed:0.112 green:0.110 blue:1.000 alpha:1.000] forState:UIControlStateNormal];
        [self.phoneLabel.titleLabel setFont:[UIFont systemFontOfSize:18 * suitableScreen_Width]];
        
        self.labelDele = [[UILabel alloc]initWithFrame:CGRectMake(275 * suitableScreen_Width, 75 * suitableScreen_Width, 90 * suitableScreen_Width, 25 * suitableScreen_Width)];
        [self.labelDele setFont:[UIFont systemFontOfSize:18 * suitableScreen_Width]];
        [self.contentView addSubview:_labelDele];
        [_labelDele setText:@"⬅️删除⬅️"];
        [_labelDele setTextAlignment:NSTextAlignmentRight];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    return self ;
}

-(void)getCollect : (PreferentialModel * )model
{
    [self.modelNameLabel setText:model.modelName];
    [self.dealerNameLabel setText:model.dealerName];
    NSMutableAttributedString * mutableString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@万",model.price]];
    
    NSInteger len = model.price.length ;
    
    [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, len)];
    self.decline.attributedText = mutableString ;
    
    [self.phoneLabel setTitle:[NSString stringWithFormat:@"☎️电话咨询%@",model.phone] forState:UIControlStateNormal];
    
    NSMutableAttributedString * mutableString1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@万",model.decline]];
    
    NSInteger len1 = model.decline.length ;
    
    [mutableString1 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, len1)];
    self.priceLabel.attributedText = mutableString1 ;
    
    
    self.priceLabel.attributedText = mutableString1 ;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
